package com.faxsun.admin.service.type;

import java.io.Serializable;
import java.util.LinkedHashMap;

import org.broadleafcommerce.common.BroadleafEnumerationType;

public class FSSkuStatus implements Serializable, BroadleafEnumerationType {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6712486148026540394L;
	private static final LinkedHashMap<String, FSSkuStatus> TYPES = new LinkedHashMap<String, FSSkuStatus>();

	public static final FSSkuStatus UNSHELVES = new FSSkuStatus("UNSHELVES",
			"下架");
	public static final FSSkuStatus SHELVES = new FSSkuStatus("SHELVES", "上架");
	public static final FSSkuStatus BEFORE_SHELVES = new FSSkuStatus(
			"BEFORE_SHELVES", "待上架");
	public static final FSSkuStatus UNKNOWN = new FSSkuStatus("UNKNOWN", "未指定");

	private String type;
	private String friendlyType;

	public static FSSkuStatus getInstance(final String type) {
		return TYPES.get(type);
	}

	private FSSkuStatus() {
	}

	private FSSkuStatus(String type, String friendlyType) {
		setType(type);
		this.friendlyType = friendlyType;
	}

	@Override
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
		if (!TYPES.containsKey(type)) {
			TYPES.put(type, this);
		}
	}

	@Override
	public String getFriendlyType() {
		return friendlyType;
	}

	public void setFriendlyType(String friendlyType) {
		this.friendlyType = friendlyType;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!getClass().isAssignableFrom(obj.getClass()))
			return false;
		FSSkuStatus other = (FSSkuStatus) obj;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}
}
